xl: Rewrite trim()
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 15 Jun 2015 14:51:23 +0000 (15:51 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 16 Jul 2015 15:58:59 +0000 (16:58 +0100)
commite316316fd68ed766948f19f07cfb6d871edf0286
treefddfd37752d0a1176bf2641611e135e1ce044ff8
parent40e0895640313f57363c0d092b2ee86910c4a479
xl: Rewrite trim()

This function would produce a NULL output pointer if the input was an
empty string, leading to a crash.

I don't think this is likely to be a security problem, as the two call
sites involve configuration options which callers are unlikely to
expose to other-than-fully-trusted input.

Also, the function would needlessly copy the input string (which I
care about not for performance reasons but because it makes the memory
handling more confusing), and would mishandle strings which contained
only predicate-true characters.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/xl_cmdimpl.c